package org.zhongyin.ErrorTesting;

import java.util.Arrays;
import java.util.List;

import org.zhongyin.Dao.ARCIVE_DBDaoImpl;
import org.zhongyin.Dao.LocalDBDaoImpl;
import org.zhongyin.Util.Utility;

public class ErrorTest {
	
	/**
	 * check the outlier based on RMSE value. If the difference between recorded and predicted value is over  as twice as RMSE
	 * send the outlier to the manager 
	 */
	public static void checkOutlier(){
		ARCIVE_DBDaoImpl dao = new ARCIVE_DBDaoImpl();
		LocalDBDaoImpl ldao = new LocalDBDaoImpl();
		float currentRecordedCL = dao.getCurrentCLData();
		List<Object[]> currentPredictionCL = ldao.getPredictionCurrentHour();
		for(Object[] element: currentPredictionCL){
			double error = currentRecordedCL - (double)element[3];
			if(Math.abs(error) > 2 * (double)element[5]){
				System.out.println("Outlier: " + Arrays.toString(element));
			}
		}
		
		Utility.printArrayList(currentPredictionCL);
		System.out.println("Recorded value: " + currentRecordedCL);
	}
	

}
